﻿using System;
using Behavioral;
using NUnit.Framework;

namespace Calculator.NUnit
{
    [TestFixture]
    public class AddingTwoPositiveNumbersShouldGiveCorrectResult : UnitTest<Calculator, int>
    {
        [Test]
        public override void Run()
        {
            GivenThat<CalculatorIsDefaultConstructed>()

            .When<AddingTwoNumbers>(13, 45)

            .Then<ResultShouldEqual>(58);
        }
    }

    [TestFixture]
    public class AddingNumbersThatCauseOverflowShouldThrowOverflowException : UnitTest<Calculator, int>
    {
        [Test]
        public override void Run()
        {
            GivenThat<CalculatorIsDefaultConstructed>()

            .When<AddingTwoNumbers>(int.MaxValue, 1)

            .ThenThrow(typeof(OverflowException));
        }
    }

    [TestFixture]
    public class ActionsShouldBeUsableAsInitializers : UnitTest<Calculator, int>
    {
        [Test]
        public override void Run()
        {
            GivenThat<TestingMutableActionAsInitializer>()

            .When<AddingTwoNumbers>(int.MaxValue, 1)

            .ThenThrow(typeof(OverflowException));
        }
    }

    [TestFixture]
    public class ActionsShouldBeUsableAsInitializers2 : UnitTest<Calculator>
    {
        [Test]
        public void ConstructorShouldBeUsableAsInitializer()
        {
            GivenThat<TestingMutableActionAsInitializer>();
        }
    }
}
